class LoanCalculator {
    public static void main(String[] args) {
        double loanAmount = 100; // 贷款总额，单位：万元
        int loanPeriodMonths = 12; // 贷款时间，单位：
        double annualInterestRate = 0.05; // 年利率
        double monthlyInterestRate = annualInterestRate / 12; // 月利率

        double[] interests = calculateInterests(loanAmount, loanPeriodMonths, monthlyInterestRate);
        System.out.println("等额本金总利息： " + interests[0] + " 万元");
        System.out.println("等额本息总利息： " + interests[1] + " 万元");
    }

    public static double[] calculateInterests(double a, int m, double i) {
        double totalInterestEqualPrincipal = ((m + 1) * a * i) / 2;
        double totalPaymentEqualInstallment = (m * a * i * Math.pow(1 + i, m)) / (Math.pow(1 + i, m) - 1);
        double totalInterestEqualInstallment = totalPaymentEqualInstallment - a;

        return new double[]{totalInterestEqualPrincipal, totalInterestEqualInstallment};
    }
}